//Message constructor.
function Message(element) {
	this.Lines = new Array(20);
	this.Element = element;
	this.clear();
	this.refreshLines();
}

Message.prototype.clear = function() {
	for(var i=0;i<20;i++) {
		this.Lines[i] = "";
	}
}

Message.prototype.addMsg = function(str) {
	for (var i=0;i<20;i++) {
		this.Lines[i]=this.Lines[i+1];
	}
	this.Lines[19]=str;
	this.refreshLines();
}

Message.prototype.refreshLines = function() {
	var disp="";
	for (var i=19;i>-1;i--) {
		disp+=this.Lines[i].replace(/ /gi,"&nbsp;").replace(/~/gi," ");
		disp+="<br>";
	}
	document.getElementById("Menu").innerHTML=disp;
}

//Add menu stuff here.
Message.prototype.createMenu = function() {
	
}

Message.prototype.assignStats = function(remaining) {
	//               12345678901234567890123456789012345678901234567890123456789012345678901234567890
	this.Lines[19]= "";
	this.Lines[18]= "                                   Attributes";
	this.Lines[17]= "";
	this.Lines[16]= "    Attributes determine the starting point for your skills and are used to";
	this.Lines[15]= " calculate your ability to perform skills you have not yet been trained in.";
	this.Lines[14]= " Untrained skills are calculated at half of the level that trained skills start";
	this.Lines[13]= " at. Some skills are automatically added as they have no cost. These skills";
	this.Lines[12]= " will be calculated as if they had been trained. (Select and Attribute then hit";
	this.Lines[11]= " +/- to increase/decrease.";
	this.Lines[10]= "";
	this.Lines[9] = "                                     <a~href='docs/Skills.html'~target='_blank'>Skills</a>";
	this.Lines[8] = "";
	this.Lines[7] = "                              Points Remaining: "+remaining;
	this.Lines[6] = "";
	this.Lines[5] = "               7. Strength         8. Toughness        9. Charisma";
	this.Lines[4] = "               4. Dexterity        5. Agility          6. Preception";
	this.Lines[3] = "               1. Intelligence     2. Willpower        3. Spirit";
	this.Lines[2] = "               r. Re-Roll          0. Speed            c. Clear";
	this.Lines[1] = "               +. Increase         `. Done             -. Decrease";
	this.Lines[0] = "";
	
	this.refreshLines();
}

Message.prototype.mainMenu = function() {
	//               12345678901234567890123456789012345678901234567890123456789012345678901234567890
	this.Lines[19]= "";
	this.Lines[18]= "                                  Runebearer-RL";
	this.Lines[17]= "";
	this.Lines[16]= "    This rogue-like is based loosely on the pen and paper RPG by Chris Morgan";
	this.Lines[15]= " called Runebearer. If you wish to learn more visit <a~href='http://www.runebearer.com'~target='_blank'>www.runebearer.com</a>. More";
	this.Lines[14]= " than a few of the gameplay mechanics required changes to fit into a";
	this.Lines[13]= " rogue-like. As such i would encourage you to get a few friends together and";
	this.Lines[12]= " try out Chris's version.";
	this.Lines[11]= "";
	this.Lines[10]= "    If you find yourself lost in the world don't worry there are some resources ";
	this.Lines[9] = " packaged that will help you in your travels.";
	this.Lines[8] = "";
	this.Lines[7] = "";
	this.Lines[6] = "                <a~href='docs/Main.html'~target='_blank'>Hitch-Hikers Guide to the Runebearer-RL Universe</a>";
	this.Lines[5] = "";
	this.Lines[4] = "";
	this.Lines[3] = "                                  1. New Game";
	this.Lines[2] = "                                  2. Load Game";
	this.Lines[1] = "                                  3. Save Game";
	this.Lines[0] = "";

	this.refreshLines();
}

Message.prototype.skills = function(msg,arr) {
	this.Lines[19]= "";
	this.Lines[18]= "                                     Skills";
	this.Lines[17]= "";
	this.Lines[12]= "                 +----------------------------------------------+";
	for(var i=0;i<11;i++) {
		this.Lines[11-i] = "                 |   "+arr[i] + "   |";
		if (i==5) this.Lines[11-i] = "                 |<b> - "+arr[i]+" - </b>|";
	}
	this.Lines[0] = "                 +----------------------------------------------+";
	this.refreshLines();
}